<template>
   
    <div class="newsinfo">
       
       <h3 class="title">{{newsInfo.newsTitle}}</h3>
       <p class="subtitle">
           <span>发表时间:{{newsInfo.newsDate | dateFmt()}}</span>
          <span>发布人:{{newsInfo.a_name}}</span>
           <span>点击：{{newsInfo.readNum}}次</span>
       </p>
       <hr>
        <div class="content" v-html="newsInfo.newsContent">
            {{newsInfo.newsContent}}
        </div>
    </div>
   
</template>
<script>

import moment from 'moment'
export default {
    filters:{
      "dateFmt":function(str){
        return moment(str).format("YYYY-MM-DD HH:mm:ss");
      }
    },

    data(){
        return {
            id:this.$route.params.id,
            newsInfo:{}
        }
    },
    methods:{
        //根据id获取某一条新闻
        getInfo(){
            this.$ajax({
                url:"before/findNews/"+this.id,
                method:"get"

            }).then(resp=>{
                this.newsInfo = resp.data.message[0];
            });

        }
    }, 
    created(){
        this.getInfo();
    }
}

</script>
<style scoped>
.newsinfo{
    padding:8px 4px;
}
.title{
    font-size: 33px;
    text-align: center;
    margin: 15px 0;
    color:red;

}
.subtitle{
    font-size: 13px;
    color:#226aff;
    display: flex;
    justify-content: space-between;
}

</style>
